<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="ot" uri="http://www.ideyatech.com/tides"%>
<%@ taglib prefix="idy" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<idy:bs-iris-header title_webpage="title.program" arg="${program.name}">
	<link rel="stylesheet" type="text/css" href="${url_style}/iris-patient-program.css" />
</idy:bs-iris-header>
<div class="page-body">
	<c:if test="${param.action eq 'create'}">
		<div class="alert alert-success">Program successfully created.</div>
	</c:if>
	<c:if test="${param.action eq 'update'}">
		<div class="alert alert-success">Program successfully updated.</div>
	</c:if>
	<c:if test="${param.item eq 'treatment'}">
		<div class="alert alert-success">Treatment successfully added.</div>
	</c:if>
	<c:if test="${param.action eq 'delete'}">
		<div class="alert alert-success">Treatment successfully removed.</div>
	</c:if>
	<div class="pull-left"><h4><span class="oranged">Program: ${program.name}</span></h4></div>
	<div class="pull-right">
		<a class="btn btn-primary btn-small" href="${url_context}/patient-program/form.jspx?id=${program.id}&action=update"><i class="icon-edit icon-white"></i> Update</a> <a class="delete-program btn btn-small"><i class="icon-remove"></i> Delete</a>
	</div>
	<div class="clear"></div>
	<hr/>
	<div class="pull-left info">
		<dl class="dl-horizontal">
			<dt>Patient</dt>
			<dd><a href="${url_context}/patient.jspx?id=${program.patient.id}">${program.patient.fullName}</a></dd>
			<dt>Created by</dt>
			<dd>${program.createdBy.prettyName}</dd>
			<dt>Description</dt>
			<dd>${program.description}<c:if test="${empty program.description}"><span class="muted">Not specified</span></c:if></dd>
			<dt>&nbsp;</dt>
			<dd>&nbsp;</dd>
			<dt>Goals</dt>
			<dd>${program.goal}<c:if test="${empty program.goal}"><span class="muted">Not specified</span></c:if></dd>
			<dt>&nbsp;</dt>
			<dd>&nbsp;</dd>
			<dt>Result</dt>
			<dd>${program.resultStatus.value}</dd>
			<dt>Result Summary</dt>
			<dd>${program.resultSummary}<c:if test="${empty program.resultSummary}"><span class="muted">Not specified</span></c:if></dd>
		</dl>
	</div>
	<div class="program-treatments pull-right">
		<div class="well">
			<ul class="nav nav-list">
				<li><span class="oranged"><strong>Treatments</strong></span></li>
				<li class="divider"></li>
				<c:if test="${empty program.medicalProgramTreatments}"><span class="muted">There are no treatments associated with this program.</span></c:if>
				<c:if test="${fn:length(program.upcomingTreatments) > 0}">
					<li class="nav-header">Upcoming</li>
					<c:forEach items="${program.upcomingTreatments}" var="treatment">
						<li><a href="${url_context}/program-treatment.jspx?id=${treatment.id}">${treatment.procedure.name}</a></li>
					</c:forEach>
				</c:if>
				<c:if test="${fn:length(program.completedTreatments) > 0}">
					<li class="nav-header">Completed</li>
					<c:forEach items="${program.completedTreatments}" var="treatment">
						<li><a href="${url_context}/program-treatment.jspx?id=${treatment.id}">${treatment.procedure.name}</a></li>
					</c:forEach>
				</c:if>
				<li class="divider"></li>
				<a class="btn btn-small btn-primary btn-block" href="${url_context}/program-treatment/form.jspx?programId=${program.id}&action=create"><i class="icon-plus icon-white"></i> Add</a>
			</ul>
		</div>
	</div>
	<div class="clear"></div>
</div>

<idy:bs-iris-footer>
	<script type="text/javascript">
		$(document).ready(function(){
			$('.show-preview').click(function(){
				var elemId = $(this).attr("id"),
				elemIndex = elemId.split("-")[2];
				IRIS.ajaxUtil.ajaxInclude('${url_context}/program-treatment.jspx?peak=true&id='+elemIndex,'treatment-preview-wrapper');
			});
			
			$('.delete-program').click(function(){
				if(confirm("Are you sure you want to remove this program?")){
					window.location = "${url_context}/patient-program/delete.jspx?id=${program.id}";
				}
			});
			
			$('#accordion').accordion();
		});
	
	</script>
</idy:bs-iris-footer>